import request from '@/config/axios'
import type { FormVO, ModelVO, ModelPageReqVO, ModelExcelReqVO } from './types'

// 查询模型列表
export const getModelPageApi = async (params: ModelPageReqVO) => {
  return await request.get({ url: '/cms/model/page', params })
}

//查询模型列表 根据模型类型
export const getModelList = async (modelType: number) => {
  return await request.get({ url: '/cms/model/list?modelType=' + modelType })
}

// 查询模型详情
export const getModelApi = async (id: number) => {
  return await request.get({ url: '/cms/model/get?id=' + id })
}

// 新增模型
export const createModelApi = async (data: ModelVO) => {
  return await request.post({ url: '/cms/model/create', data })
}

// 修改模型
export const updateModelApi = async (data: ModelVO) => {
  return await request.put({ url: '/cms/model/update', data })
}

// 删除模型
export const deleteModelApi = async (id: number) => {
  return await request.delete({ url: '/cms/model/delete?id=' + id })
}

// 导出模型 Excel
export const exportModelApi = async (params: ModelExcelReqVO) => {
  return await request.download({ url: '/cms/model/export-excel', params })
}

// 更新表单定义
export const updateFormApi = async (data: FormVO) => {
  return await request.post({
    url: '/cms/model/updateField',
    data: data
  })
}

// 获得表单定义
export const getFormApi = async (id: number) => {
  return await request.get({
    url: '/cms/model/get?id=' + id
  })
}
